package com.mini.mybatis.mybatisministep09.type;

import com.mini.mybatis.mybatisministep09.sqlsession.configuration.Configuration;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 类型处理器基类
 * @param <T>
 */
public abstract class BaseTypeHandler<T> implements TypeHandler<T> {

    protected Configuration configuration;

    public void setConfiguration(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {

        // 模板方法，具体的交由子类实现，不同类型的属性设置
        setNoNullParameter(ps,i,parameter,jdbcType);

    }

    protected abstract void setNoNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException;
}
